<?php

class InvitationMessage extends Zend_Db_Table_Abstract {
	protected $_name = 'invitation_message';
	protected $_primary = 'id';
	
	protected $_referenceMap = array(
		'Invitation' => array(
			'columns' => array('invitation_id'),
			'refTableClass' => 'Invitation',
			'refColumns' => array('id')
		),
		'Message' => array(
			'columns' => array('message_id'),
			'refTableClass' => 'Message',
			'refColumns' => array('id')
		)
	);
	
	/**
	 * Find by id.
	 * 
	 * @param $id
	 * return invitation message
	 */
	public static function findById($id) {
		$invitationMessage = new InvitationMessage();
		return $invitationMessage->find($id)->current();
	}
	
	/**
	 * Add entry.
	 * 
	 * @param $data insert data
	 * @return return new inserted id
	 */
	public function addEntry($data) {
		return $this->insert($data);
	}
	
	/**
	 * Delete invitation message by given invitation id and message id.
	 * 
	 * @param $invitation_id
	 * @param $message_id
	 */
	public function deleteByInvitationAndMessageId($invitation_id, $message_id) {
//		$select = $this->select()->where('invitation_id=?', $invitation_id)
//		->where('message_id=?', $message_id);
		$this->delete('invitation_id='.$invitation_id." and message_id=".$message_id);
	}
} 
?>